require_relative 'lib'
require_relative 'slot'

$stdout.sync = true

$lr = 1
$card = 'I'
$slot = 0

def parse_enemy_step
  $lr = $stdin.gets.chomp.to_i

  case $lr
    when 1
      $card = $stdin.gets.chomp
      $slot = $stdin.gets.to_i
    when 2
      $slot = $stdin.gets.chomp.to_i
      $card = $stdin.gets.chomp

  end

  do_application($lr, $slot, $card)
  swap_slots
end

player_id = ARGV[0].to_i

parse_enemy_step if(player_id == 1)

while true
  #decide wat to do here
  do_application($lr, $slot, $card)
  swap_slots

  $stdout.puts $lr
  case $lr
    when 1
      $stdout.puts $card
      $stdout.puts $slot
    when 2
      $stdout.puts $slot
      $stdout.puts $card
  end

  parse_enemy_step
end
